{% extends 'setup/base.twig' %}
{% block content %}

<form id="select_lang" method="post" action="../setup/{{ url('/setup') }}">
  {{ get_hidden_inputs() }}
  <bdo lang="en" dir="ltr">
    <label for="lang">
      {{ t('Language') }}
      {{ t('Language') != 'Language' ? ' - Language' }}
    </label>
  </bdo>
  <br>
  <select id="lang" name="lang" class="autosubmit" lang="en" dir="ltr">
    {% for language in languages %}
      <option value="{{ language.code }}"{{ language.is_active ? ' selected' }}>{{ language.name|raw }}</option>
    {% endfor %}
  </select>
</form>

<h2>{{ t('Overview') }}</h2>

<a href="#" id="show_hidden_messages" class="hide">
  {{ t('Show hidden messages') }} (#MSG_COUNT)
</a>

{% for message in messages %}
  <div class="{{ message.type }}{{ message.is_hidden ? ' hiddenmessage' }}" id="{{ message.id }}">
    <h4 class="fs-6">{{ message.title }}</h4>
    {{ message.message|raw }}
  </div>
{% endfor %}

<div class="card mb-3">
  <div class="card-header">{{ t('Servers') }}</div>

  <div class="card-body">
  <form method="get" action="../setup/{{ url('/setup') }}" class="config-form disableAjax">
    <input type="hidden" name="tab_hash" value="">
    {% if has_check_page_refresh %}
      <input type="hidden" name="check_page_refresh" id="check_page_refresh" value="">
    {% endif %}
    {{ get_hidden_inputs('', '', 'server') }}
    {{ get_hidden_fields({'page': 'servers', 'mode': 'add'}, '', true) }}

  <div class="form">
    {% if server_count > 0 %}
      <table class="table w-auto datatable">
        <tr>
          <th>#</th>
          <th>{{ t('Name') }}</th>
          <th>{{ t('Authentication type') }}</th>
          <th colspan="2">DSN</th>
        </tr>

        {% for server in servers %}
          <tr>
            <td>{{ server.id }}</td>
            <td>{{ server.name }}</td>
            <td>{{ server.auth_type }}</td>
            <td>{{ server.dsn }}</td>
            <td class="text-nowrap">
              <small>
                <a href="../setup/{{ url('/setup', server.params.edit) }}">
                  {{ t('Edit') }}
                </a>
                |
                <a class="delete-server" href="../setup/{{ url('/setup', server.params.remove) }}" data-post="
                  {{- get_common({token: server.params.token}, '', false) }}">
                  {{ t('Delete') }}
                </a>
              </small>
            </td>
          </tr>
        {% endfor %}
      </table>
    {% else %}
      <table class="table mb-0">
        <tr>
          <td>
            <em>{{ t('There are no configured servers') }}</em>
          </td>
        </tr>
      </table>
    {% endif %}

    <table class="table mb-0">
      <tr>
        <td class="lastrow text-start">
          <input type="submit" name="submit" value="{{ t('New server') }}">
        </td>
      </tr>
    </table>
  </div>

  </form>
  </div>
</div>

<div class="card">
  <div class="card-header">{{ t('Configuration file') }}</div>

  <div class="card-body">
  <form method="post" action="../setup/{{ url('/setup/show-config') }}" class="config-form disableAjax">
    <input type="hidden" name="tab_hash" value="">
    {% if has_check_page_refresh %}
      <input type="hidden" name="check_page_refresh" id="check_page_refresh" value="">
    {% endif %}
    {{ get_hidden_inputs('', '', 'server') }}

  <table class="table table-borderless">
    <tr>
      <th>
        <label for="DefaultLang">{{ t('Default language') }}</label>
        <span class="doc">
          <a href="{{ get_docu_link('config', 'cfg_DefaultLang', '../') }}" target="_blank" rel="noreferrer noopener">
            {{- get_image('b_help', t('Documentation')) -}}
          </a>
        </span>
      </th>
      <td>
        <select name="DefaultLang" id="DefaultLang" class="w-75">
          {% for language in languages %}
            <option value="{{ language.code }}"{{ language.is_active ? ' selected' }}>{{ language.name|raw }}</option>
          {% endfor %}
        </select>
      </td>
    </tr>

    <tr>
      <th>
        <label for="ServerDefault">{{ t('Default server') }}</label>
        <span class="doc">
          <a href="{{ get_docu_link('config', 'cfg_ServerDefault', '../') }}" target="_blank" rel="noreferrer noopener">
            {{- get_image('b_help', t('Documentation')) -}}
          </a>
        </span>
      </th>
      <td>
        <select name="ServerDefault" id="ServerDefault" class="w-75">
          {% if server_count > 0 %}
            {% if server_count > 1 %}
              <option value="0">{{ t('let the user choose') }}</option>
              <option value="" disabled>------------------------------</option>
            {% endif %}
            {% for server in servers %}
              <option value="{{ server.id }}"{{ server.id == 1 ? ' selected' }}>{{ server.name }} [{{ server.id }}]</option>
            {% endfor %}
          {% else %}
            <option value="1">{{ t('- none -') }}</option>
          {% endif %}
        </select>
      </td>
    </tr>

    <tr>
      <th><label for="eol">{{ t('End of line') }}</label></th>
      <td>
        <select name="eol" id="eol" class="w-75">
          <option value="unix"{{ eol == 'unix' ? ' selected' }}>UNIX / Linux (\n)</option>
          <option value="win"{{ eol == 'win' ? ' selected' }}>Windows (\r\n)</option>
        </select>
      </td>
    </tr>

    <tr>
      <td colspan="2" class="lastrow text-start">
        <input type="submit" name="submit_display" value="{{ t('Display') }}">
        <input type="submit" name="submit_download" value="{{ t('Download') }}">
        <input class="red" type="submit" name="submit_clear" value="{{ t('Clear') }}">
      </td>
    </tr>
  </table>

  </form>
</div>
</div>

<div id="footer">
  <a href="../{{ url('/url', {'url': 'https://www.phpmyadmin.net/'}) }}">{{ t('phpMyAdmin homepage') }}</a>
  <a href="../{{ url('/url', {'url': 'https://www.phpmyadmin.net/donate/'}) }}">{{ t('Donate') }}</a>
  <a href="../setup/{{ url('/setup', {'version_check': true}) }}">{{ t('Check for latest version') }}</a>
</div>

{% endblock %}
